package com.tom.controller;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.tom.common.Constans;
import com.tom.common.Result;
import com.tom.service.UtilService;

@Controller  
@RequestMapping(value = "util")  
public class UtilController {
	@Autowired  
    private UtilService utilService; 
	//展示用户详情
    @RequestMapping(value = "showOption", method = {RequestMethod.GET, RequestMethod.POST})  
    @ResponseBody  
    public Object showOption(@RequestBody String json) throws NoSuchAlgorithmException, UnsupportedEncodingException  {  
		@SuppressWarnings("unchecked")
		HashMap<String, String> map = (HashMap<String, String>)JSON.parseObject(json, Map.class);
    	Result result = new Result();
    	List<HashMap<String, String>> list = utilService.showOption(map);
    	result.setStatus(Constans.STATUS_SUCCESS);
        result.setResult(list);
        return JSON.toJSON(result);
    }  
}
